| Server IP : 43.153.74.48 / Your IP : 216.73.216.28 Web Server : LiteSpeed System : Linux VM-0-13-ubuntu 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 User : www ( 1002) PHP Version : 8.1.29 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/stainlesstint.com/wp-content/themes/woodmart/js/scripts/wc/ |
Upload File : |
/* global woodmart_settings */
(function($) {
woodmartThemeModule.singleProdReviewsLike = function () {
let $reviewsTab = $('#reviews');
$reviewsTab
.on( 'click', '.wd-review-likes .wd-like, .wd-review-likes .wd-dislike', function() {
let isUserLoggedIn = $('body').hasClass('logged-in');
let $headerMyAccountElement = $('.whb-main-header .wd-header-my-account');
let isLoginSide = $headerMyAccountElement.length > 0 && $headerMyAccountElement.hasClass('login-side-opener');
let vote;
let $this = $(this);
let $voteWrapper = $this.closest('.wd-review-likes');
let commentIDAttr = $this.closest('.comment_container').attr('id');
let commentID = parseInt(commentIDAttr.substring(commentIDAttr.indexOf('-') + 1));
if ( ! isUserLoggedIn && isLoginSide ) {
$('.login-side-opener')
.trigger('click');
return;
} else if ( ! isUserLoggedIn ) {
window.location.href = woodmart_settings.myaccount_page;
return;
}
if ( $this.hasClass('wd-active') ) {
return;
}
$this.siblings().removeClass( 'wd-active' );
$this.addClass('wd-active');
if ( $this.hasClass('wd-like') ) {
vote = 'like';
} else if ( $this.hasClass('wd-dislike') ) {
vote = 'dislike';
}
$.ajax({
url : woodmart_settings.ajaxurl,
method : 'POST',
data : {
action: 'woodmart_comments_likes',
comment_id: commentID,
vote,
},
beforeSend: function() {
$voteWrapper.addClass('wd-adding');
},
complete: function() {
$voteWrapper.removeClass('wd-adding');
},
success: function( response ) {
let $likesWrap = $this.closest('.wd-review-likes');
if ( response.hasOwnProperty( 'likes' ) ) {
$likesWrap.find('.wd-like span').text( response.likes )
}
if ( response.hasOwnProperty( 'dislikes' ) ) {
$likesWrap.find('.wd-dislike span').text( response.dislikes )
}
},
error: function( request ) {
console.error( request );
}
});
});
}
$(document).ready(function() {
woodmartThemeModule.singleProdReviewsLike();
});
})(jQuery);